package fr.vahren.sriksal.generation;

public class DefaultBiomeGenerationStrategy implements BiomeGenerationStrategy {

	private static final int WOOD_MAX_ELEVATION = 230;
	private static final int WOOD_MIN_ELEVATION = 120;
	private static final int WOOD_MAX_TEMPERATURE = 4;
	private static final int WOOD_MIN_TEMPERATURE = 2;
	private static final int WOOD_MIN_HUMIDITY = 2;
	private static final int SAND_MAX_ELEVATION = 120;
	private static final int SAND_MIN_TEMPERATURE = 4;
	private static final int SAND_MAX_HUMIDITY = 1;
	private static final int SEA_LEVEL = 90;

	@Override
	public void generateBiome(int[][] map, int[][] temperatureMap,
			int[][] humidityMap, int[][] waterMap, int[][] terrainMap,
			int[][] biomeMap) {
		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[i].length; j++) {
				if (waterMap[i][j] == 0 && terrainMap[i][j] > 0
						&& map[i][j] <= WOOD_MAX_ELEVATION
						&& map[i][j] >= WOOD_MIN_ELEVATION
						&& temperatureMap[i][j] <= WOOD_MAX_TEMPERATURE
						&& temperatureMap[i][j] >= WOOD_MIN_TEMPERATURE
						&& humidityMap[i][j] >= WOOD_MIN_HUMIDITY) {// WOOD
					biomeMap[i][j] = Eroder.WOOD;
				} else if (terrainMap[i][j] > 0
						&& (map[i][j] <= SEA_LEVEL + 5 || (map[i][j] <= SAND_MAX_ELEVATION
								&& temperatureMap[i][j] >= SAND_MIN_TEMPERATURE && humidityMap[i][j] <= SAND_MAX_HUMIDITY))) {// SAND
					biomeMap[i][j] = Eroder.SAND;
				}
			}
		}
	}

}
